


        Vue.component('v-header',{
            template:`<header>
            <p class="colorLine ready"><img v-if="commonIcon.length" :src="commonIcon[0]" class="obj-c" alt=""></p>
            <div class="fluid flex flex-align-items">
                 <a v-if="nav.length" :href="nav[0].visitUrl" class='logo'><img :src="webBasicInf.logoImg" alt=""></a>
                 <div class="language">
                     <div class="mid">
                         <div class="inner">
                             <p>En</p>
                             <p>Ch</p>
                         </div>
                     </div>
                 </div>
                 <nav>
                     <div class="language">
                         <div class="mid">
                             <div class="inner">
                                 <p>English</p>
                                 <p>Chinese</p>
                             </div>
                         </div>
                     </div>
                     <div class="links">
                         <div v-for="(item,i) in nav" class="itm">
                             <a :href="item.visitUrl">
                              <span>{{item.name}}</span>
                              <span class="fill"><i>{{item.name}}</i></span>
                             </a>
                             <div class="sonMenu" v-if="item.navbarDtos.length != 0 && i != nav.length - 1">
                                <ul class="inner">
                                    <li v-for="(sonItem,n) in item.navbarDtos">
                                      <a :href="sonItem.visitUrl">
                                          {{sonItem.name}}
                                      </a>
                                    </li>
                                </ul>
                             </div>
                         </div>
                     </div>
                 </nav>
                 <div class="menuBtn cursor">
                     <span class='g hvc'></span>
                     <span class="o hvc"></span>
                     <span class="b hvc"></span>
                 </div>
            </div>   
        </header>`,
            data:function(){
                return{
                  webBasicInf:{},
                  nav:[],
                  //currentLinkInd:'',
                  commonIcon:[]
                }
            },
            created:function(){
              //获取网站基本信息
              axios.get(dataUrl + 'api/getWebsite',{
                headers:{
                  Authorization: headers
                }
              })
              .then((res) => {
                //console.log(res.data.data);
                this.webBasicInf = res.data.data;
              })
              //获取导航栏
              axios.get(dataUrl + 'api/getNavbar',{
                headers:{
                  Authorization: headers
                }
              })
              .then((res) => {
                //console.log(res.data.data);
                this.nav = res.data.data;
                /*for(var a = 1;a < this.nav.length;a++){
                  if(window.location.href.indexOf(this.nav[a].visitUrl) >= 0){
                    this.currentLinkInd = a - 1;
                    break;
                  }
                }*/
                setTimeout(function(){
                  if($('.mobileDevice').length){
                      $('header .fluid nav .links .itm>a').click(function(e){
                              linkHref = $(this).attr('href');
                              if($(this).siblings('.sonMenu').length){
                                  if($(this).parent()[0].className.indexOf('show') < 0){
                                    e = e || window.event;
                                      e.cancelBubble = true;
                                      e.stopPropagation();
                                      if(e.preventDefault){ // w3c
                                          e.preventDefault();
                                      } else { // ie
                                          e.returnValue = false;
                                      }
                                      $('header .fluid nav .links .itm').removeClass('show');
                                      $(this).parent().addClass('show');
                                  }   
                              }
                      })
                  }else{
                      $('header .fluid nav .links .itm>a').mouseenter(function(){
                          $(this).parent().addClass('show');
                      })
                      $('header .fluid nav .links .itm>a').mouseleave(function(){
                          var This = $(this);
                              disappear = setTimeout(function(){
                                  This.parent().removeClass('show');
                              },100)
                      })
                      $('header .fluid nav .links .itm .sonMenu').mouseenter(function(){
                          if(disappear){
                              clearTimeout(disappear);
                              disappear = null;
                          }
                      })
                      $('header .fluid nav .links .itm .sonMenu').mouseleave(function(){
                          if($(this).parent()[0].className.indexOf('show') >= 0){
                              $(this).parent().removeClass('show');
                          }
                      })
                  }
                },10)
              });

              //获取公共图标
              axios.post(dataUrl + 'api/getBanner',{identification:'COMMON_ICON'},{
                headers:{
                  Authorization: headers
                }
              })
              .then((res) => {
                //console.log(res.data.data);
                for(var n = 0;n < res.data.data.length;n++){
                  if(res.data.data[n].remark == 'headLine'){
                    this.commonIcon.push(res.data.data[n].imgPath);
                  }
                }
              });
            }
        });